﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace Exact_Extension
{
    public partial class MsgDeleteInvoice : DevExpress.XtraEditors.XtraForm
    {
        Common common;
        ISHCMC_Invoice InvoiceDetail;
        public MsgDeleteInvoice(ISHCMC_Invoice _InvoiceDetail, Common _common)
        {
            InitializeComponent();
            common = _common;
            InvoiceDetail = _InvoiceDetail;
        }

        private void btnDelete_Click(object sender, EventArgs e)
        {
             MsgConfirm msg = new MsgConfirm();
             DialogResult resultConfirm = msg.ShowDialog();
             if (resultConfirm == DialogResult.OK)
             {

                 int i = common.DeleteInvoice(InvoiceDetail);

                 if (i > 0)
                 {
                     this.DialogResult = DialogResult.OK;
                     common.ProcessTrackingInvoice(InvoiceDetail, this.txtReason.Text, "Delete");
                 }
                 else
                 {
                     this.DialogResult = DialogResult.No;
                 }
             }

        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;           
            this.Close();
            
        }
    }
}